using System;
using UnityEngine;

public class LoadingHandler : MonoBehaviour
{
	private void Start()
	{
		Action doLoad = delegate()
		{
			DWATTLight.logEvent("LoadCompleteTime", new object[]
			{
				Time.realtimeSinceStartup.ToString(),
				"IN"
			});
			this.asyncOp = Application.LoadLevelAsync("play");
			Handheld.StartActivityIndicator();
		};
		BMConsent.Begin(delegate
		{
			doLoad();
		});
	}

	private void StretchScale()
	{
		Texture mainTexture = base.GetComponent<Renderer>().sharedMaterial.mainTexture;
		Rect screenExtents = this.cam.ScreenExtents;
		float num = (float)mainTexture.width / (float)mainTexture.height;
		float num2 = screenExtents.width / screenExtents.height;
		if (num > num2)
		{
			base.transform.localScale = new Vector3(screenExtents.height * num, screenExtents.height, 1f);
		}
		else
		{
			base.transform.localScale = new Vector3(screenExtents.width, screenExtents.width / num, 1f);
		}
	}

	private void Update()
	{
		if (this.asyncOp == null)
		{
			return;
		}
		float num = this.asyncOp.progress;
		if (num > 1f)
		{
			num = 1f;
		}
		this.SetProgress(num * 100f);
	}

	private void SetProgress(float progressValue)
	{
		this.progress.Percent = progressValue;
	}

	public tk2dCamera cam;

	public tk2dProgress progress;

	private AsyncOperation asyncOp;
}
